<!--Written By BlokerStudio All Members.-->
<!--代码由方块盒子全体成员撰写-->
<!--了解服务条款:"https://blokerstudio.cn/tos"-->
<!--
 _____   _       _____   _   _    _____   _____         _____   _____   _   _   _____   _   _____  
|  _  \ | |     /  _  \ | | / /  | ____| |  _  \       /  ___/ |_   _| | | | | |  _  \ | | /  _  \ 
| |_| | | |     | | | | | |/ /   | |__   | |_| |       | |___    | |   | | | | | | | | | | | | | | 
|  _  { | |     | | | | | |\ \   |  __|  |  _  /       \___  \   | |   | | | | | | | | | | | | | | 
| |_| | | |___  | |_| | | | \ \  | |___  | | \ \        ___| |   | |   | |_| | | |_| | | | | |_| | 
|_____/ |_____| \_____/ |_|  \_\ |_____| |_|  \_\      /_____/   |_|   \_____/ |_____/ |_| \_____/ 
-->
<?php
//方块盒子版权所有 CubeUserSystem
//如果程序在热铁盒服务器中，请把数据库文件后缀改为.rth，不要用json
//如果在自己的服务器中，请确保外部不能直接读取到数据库json内容
//调用数据库
$setting = json_decode(file_get_contents("setting/main.json"),true);
$tokendata = json_decode(file_get_contents("userdata/token.json"),true);
//主要部分
if(isset($_POST['username'],$_POST['password'])){
	$runcode = true;
}else{
	$runcode = false;
}
if($runcode == true){
	$username = $_POST['username'];
	$password = crypt($_POST['password'],$setting['cryptcode']);
	if($password == $tokendata[$username]){
		setcookie('username', $username, time() + 7*24*60*60,"/", $setting["domain"],true, true);
		setcookie('token', $password, time() + 7*24*60*60,"/", $setting["domain"],true, true);
		header("location:".$setting["jump"]);
	}
}else{
	echo "<b><a style='color:red;'>[方块盒子 ERROR]</a></b><a> 拒绝直接访问tologin</a>";
}
?>